﻿using INNOVACALL.Framework.Common.MVCHelpers.Localization;
// ***********************************************************************
// Assembly         : INNOVACALL.Framework.Common
// Author           : LJO+01 (Laurent Jordi)
// Created          : 06-05-2013
// Last Modified By : LJO+01 (Laurent Jordi)
// Last Modified On : 06-05-2013
// ***********************************************************************
// <copyright file="CountryService.cs" company="Copyright © Innovacall 2011">
//     Copyright (c) Copyright © Innovacall 2011. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace INNOVACALL.Framework.Common.CountryCurrencyService
{
    /// <summary>
    /// Class CountryService
    /// </summary>
    public class CountryService
    {
        private string language;

        /// <summary>
        /// Gets the start with (french default)
        /// </summary>
        /// <param name="term">The term.</param>
        /// <param name="count">The count.</param>
        /// <returns>IEnumerable{System.String}.</returns>
        public IEnumerable<string> GetStartWith(string term, int count)
        {
            if (term == null)
            {
                return null;
            }
            return Country.GetValues().Where(i => i.LocalizedName.StartsWith(term, StringComparison.InvariantCultureIgnoreCase)).Select(i => i.LocalizedName).Take(count);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CountryService"/> class.
        /// </summary>
        /// <param name="language">The language.</param>
        public CountryService(string language)
        {
            this.language = language;
            INNOVACALL.Framework.Common.MVCHelpers.Localization.CommonLocalization.SetCurrentThreadLanguage(language);
            Country.GenerateCountryList();
        }

    }
}